﻿Public Class HoraireEmploye
    Dim oLocalContext As DBMainContext


    Public Sub New()

        ' Cet appel est requis par le concepteur.
        InitializeComponent()

        ' Ajoutez une initialisation quelconque après l'appel InitializeComponent().

    End Sub

    Public Sub initialise(ByVal oContext As DBMainContext)
        oLocalContext = oContext
        Dim oParam As New Param
        pbAccompagnement.BackColor = oParam.GetColorHex((From u In oLocalContext.Parametre_Couleur Where u.Nom_Param = "CouleurAccompagnement" Select u.Valeur_CouleurHex).FirstOrDefault)
        pbActivite.BackColor = oParam.GetColorHex((From u In oLocalContext.Parametre_Couleur Where u.Nom_Param = "CouleurActivite" Select u.Valeur_CouleurHex).FirstOrDefault)
        pbTache.BackColor = oParam.GetColorHex((From u In oLocalContext.Parametre_Couleur Where u.Nom_Param = "CouleurTache" Select u.Valeur_CouleurHex).FirstOrDefault)
        LoadData(dtpDate.Value)
        SchedulerMain.oDateToCheck = dtpDate.Value
        SchedulerMain.SetData(dtpDate.Value)
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        'Dim oAjoutEmployeAvecAlt As New AjoutEmployeAvecAlternatif
        'oAjoutEmployeAvecAlt.ShowDialog()
        Dim oPlan_Even As PlanificationEvenement = CType(dgvActivite.CurrentRow.DataBoundItem, PlanificationEvenement)
        SchedulerMain.AddItem(oPlan_Even.Nom, oPlan_Even, Outils.TypeEvenement.Activite)

    End Sub

    Public Sub LoadData(ByVal dDate As Date)
        Dim oArray() As PlanificationEvenement
        oArray = (From u In oLocalContext.PlanificationEvenement Where CType(u.Type, PlanificationEvenement.TypeEvenement) = PlanificationEvenement.TypeEvenement.Activite Select u).ToArray
        oArray = (From u In oArray Where u.CheckIfIsTheDay(dtpDate.Value) Select u).ToArray
        dgvActivite.DataSource = oArray

        For Each Col As DataGridViewColumn In dgvActivite.Columns
            If Not New List(Of String)(New String() {"Nom"}).Contains(Col.Name) Then
                Col.Visible = False
            End If
        Next
        SchedulerMain.Initialize(96, 15, oLocalContext, dDate)


    End Sub

End Class
